<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>双十一倒计时</title>
    <style>
        .countdown-container {
            text-align: center;
            font-size: 24px;
            margin-top: 50px;
            border: 2px solid #333;
            padding: 20px;
            max-width: 400px;
            margin: 0 auto;
        }

        .countdown {
            margin-top: 20px;
        }
    </style>
</head>
<body>
<div class="countdown-container">
    <h1>距离光棍节，还有</h1>
    <div class="countdown" id="countdown"></div>
</div>

<script>
    const countdownElement = document.getElementById('countdown');

    const targetDate = new Date('2024-11-11T00:00:00');

    function updateCountdown() {
        const currentDate = new Date();
        const timeDifference = targetDate - currentDate;

        if (timeDifference <= 0) {
            countdownElement.innerHTML = '光棍节已经开始！';
        } else {
            const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
            const hours = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
            const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60));
            const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000);

            countdownElement.innerHTML = `${days}天 ${hours}小时 ${minutes}分钟 ${seconds}秒`;
        }
    }

    updateCountdown();

    setInterval(updateCountdown, 1000);
</script>
</body>
</html>